<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ attribute name="areaTitle" type="java.lang.String" required="false" description="区县title"%>
<%@ attribute name="hospitalTitle" type="java.lang.String" required="false" description="机构title"%>
<%@ attribute name="year" type="java.lang.String" required="true" description="年度name值"%>
<%@ attribute name="area" type="java.lang.String" required="true" description="区县name值"%>
<%@ attribute name="hospitals" type="java.lang.String" required="true" description="机构name值"%>
<%@ attribute name="searchType" type="java.lang.String" required="true" description="统计方式name值"%>
<%@ attribute name="ageRange" type="java.lang.String" required="false" description="年龄段"%>
<%@ attribute name="gender" type="java.lang.String" required="false" description="性别"%>
<%@ attribute name="role" type="java.lang.String" required="true" description="角色"%>
<div class="text-l bg-1 bk-gray pd-5"  style="padding: 10px 20px;">
    <div class="radio mt-10 ml-10">
    <span>年度：</span>
    <span class="select-box" style="width: 150px">
        <select id="yearList" class="select" size="1" name="${year}" id="${year}" datatype="*" nullmsg="请选择年度！">
        </select>
    </span>

    <span class="ml-10" style="margin-left: 50px;">区（县）</span>
    <span class="select-box inline">
         <select class="select" id="${area}" name = "${area}" onchange="selectHospital()">
         </select>
    </span>

    <span class="ml-10">筛查医疗机构</span>

    <span class="select-box inline">
        <select class="select" id="${hospitals}" name="${hospitals}">
        </select>
    </span>

    <c:if test="${gender eq '1'}">
        <span class="ml-10">性别</span>
        <span class="select-box inline">
            <select id="gender" class="select" id="${gender}" name="${gender}">
                <option value="">全部</option>
                <option value="1">男</option>
                <option value="2">女</option>
            </select>
        </span>
    </c:if>
    </div>
    <c:if test="${ageRange eq '1'}">
        <div class="radio mt-10 ml-10">
        <span>年龄段：</span>
        <div class="check-box">
            <input name="ages" type="checkbox" value="1"> 0~30
        </div>
        <div class="check-box">
            <input name="ages" type="checkbox" value="2"> ~40
        </div>
        <div class="check-box">
            <input name="ages" type="checkbox" value="3"> ~50
        </div>
        <div class="check-box">
            <input name="ages" type="checkbox" value="4"> ~60
        </div>
        <div class="check-box">
            <input name="ages" type="checkbox" value="5"> ~70
        </div>
        <div class="check-box">
            <input name="ages" type="checkbox" value="6"> 70以上
        </div>
        </div>
    </c:if>

    <div class="radio ml-10">
        <c:if test="${role>=4}">
            <label class="radio-inline">
                <input type="radio" name="${searchType}" value="2"> 按医疗结构统计
            </label>
            <label class="radio-inline">
                <input type="radio" name="${searchType}" value="1"> 按区县统计
            </label>
        </c:if>
    </div>
    <div class="radio ml-10">
        <button class="btn btn-success radius r" id="search" style="position: relative; top: -30px;"><i class="Hui-iconfont">&#xe665;</i>查询</button>
    </div>
</div>

<script>
    $(function(){

        yearDown('yearList',true); //年限下拉

        jQuery.get($contextPath+"/common/dictarea",function(info){
            var role = info.data.role;

            if(role == '6'){
                jQuery("input[name='searchType']:eq(1)").attr("checked",'checked');
            }else{
                jQuery("input[name='searchType']:eq(0)").attr("checked",'checked');
            }
            var areaList = info.data.areaList;
            if(role == '2' || role == '3' || role == '6'){
                jQuery("#${area}")[0].options.add(new Option("全部",""));
            }
             for(var index = 0;index < areaList.length; index++){
                jQuery("#${area}")[0].options.add(new Option(areaList[index].explainMemo,areaList[index].code));
             }
        });

        jQuery.get($contextPath+"/common/hospital",function(info){
            var role = info.data.role;
            var hospitalList = info.data.hospitalList;
            if(role == '2' || role == '3' || role == '6'){
                jQuery("#${hospitals}")[0].options.add(new Option("全部",""));
            }
            for(var index = 0;index < hospitalList.length; index++){
                jQuery("#${hospitals}")[0].options.add(new Option(hospitalList[index].hospitalName,hospitalList[index].hospitalId));
            }
        });
    })

    function selectHospital(){
        jQuery.get($contextPath+"/common/hospital?addressCounty="+jQuery("#area").val(),function(info){
            var role = info.data.role;
            var hospitalList = info.data.hospitalList;
            var html = "";
            if(role == '2' || role == '3' || role == '6'){
                html += '<option value="">全部</option>';
            }
            for(var index = 0;index < hospitalList.length; index++){
                html += '<option value="'+hospitalList[index].hospitalId+'">'+hospitalList[index].hospitalName+'</option>'
            }
            jQuery("#${hospitals}").html(html);
        });
    }

</script>



